package com.un10.qianduan.contorller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.un10.entity.Proclass;
import com.un10.entity.Product;
import com.un10.entity.Rotationchart;
import com.un10.service.ProclassService;
import com.un10.service.ProductService;
import com.un10.service.RotaService;

@Controller
public class ProductWebContorller {
	@Autowired
	 RotaService rotaService;
	 @Autowired
	ProclassService proclassService;
	 @Autowired																																	
	 ProductService   productService;
	  @RequestMapping("/B/product")	
	  public String product(Model model, HttpSession session) {
		  //轮播图
	    List<Rotationchart> Rot = rotaService.findAllRot(0, 9999, null);
	    model.addAttribute("Rot", Rot);	
	    // 重定向到主页面的跳转方法
	    System.out.println(Rot);
	    //商品分类
	    List<Proclass> proclass = proclassService.findAllProclass(0, 9999, null);
	    model.addAttribute("proclass", proclass);	
	    // 重定向到主页面的跳转方法
//	    System.out.println(proclass);
	    
	    
	    List<Product> product = productService.findAllProduct(0, 9999, null,null);
	    model.addAttribute("product", product);	
	    // 重定向到主页面的跳转方法
//	    System.out.println(product);	      
	    
	    return "B/Product";
	  }
	  
	  @RequestMapping("/B/ProducFenlei")
		public String ProducFenlei(Model model, @RequestParam("className") String className) {
			List<Product> productfenlei = productService.findAllProductFenglei(className);
			
			model.addAttribute("productfenlei", productfenlei);
		
			// 重定向到主页面的跳转方法
			return "B/Product";
		}

	  @RequestMapping("/B/Productxiangqing")
		public String Productxiangqing(Model model, @RequestParam("proName") String proName) {
			List<Product> productCateAll = productService.findProductxiangqing(proName);
			
		model.addAttribute("CateProAll", productCateAll);
		
			// 重定向到主页面的跳转方法
			return "B/product-detail";
		}
}
